package com.example.demo.entity;

import com.example.demo.enums.Role;

import javax.persistence.*;

@Entity
@Table(name = "tb_user", indexes = {
        @Index(columnList = "phone_number")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = "phone_number")
})
public class User {
    @Id
    @Column(name = "id", updatable = false, nullable = false)
    private String id;

    @Column(name = "name", length = 64, nullable = false)
    private String name;

    @Column(name = "phone_number", length = 16, nullable = false)
    private String phoneNumber;

    @Column(name = "urgent_name", length = 64)
    private String urgentName;

    @Column(name = "urgent_number", length = 16)
    private String urgentNumber;

    @Column(name = "is_admin", nullable = false)
    private String isAdmin;

    @Column(name = "role")
    @Enumerated(EnumType.ORDINAL)
    private Role role;

    @Column(name = "avator", length = 1024)
    private String avator;

    @Column(name = "is_valid")
    private String isValid;

    @Column(name = "password", length = 256, nullable = false)
    private String password;

    private String certificationCode;

    public User(String id, String name, String phoneNumber, String urgentName, String urgentNumber, String isAdmin, Role role, String avator, String isValid, String password, String certificationCode) {
        this.id = id;
        this.name = name;
        this.phoneNumber = phoneNumber;
        this.urgentName = urgentName;
        this.urgentNumber = urgentNumber;
        this.isAdmin = isAdmin;
        this.role = role;
        this.avator = avator;
        this.isValid = isValid;
        this.password = password;
        this.certificationCode = certificationCode;
    }

    public User() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getUrgentName() {
        return urgentName;
    }

    public void setUrgentName(String urgentName) {
        this.urgentName = urgentName;
    }

    public String getUrgentNumber() {
        return urgentNumber;
    }

    public void setUrgentNumber(String urgentNumber) {
        this.urgentNumber = urgentNumber;
    }

    public String getIsAdmin() {
        return isAdmin;
    }

    public void setIsAdmin(String isAdmin) {
        this.isAdmin = isAdmin;
    }

    public String getIsValid() {
        return isValid;
    }

    public void setIsValid(String isValid) {
        this.isValid = isValid;
    }

    public String getAvator() {
        return avator;
    }

    public void setAvator(String avator) {
        this.avator = avator;
    }

    public String getValid() {
        return isValid;
    }

    public void setValid(String valid) {
        isValid = valid;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getCertificationCode() {
        return certificationCode;
    }

    public void setCertificationCode(String certificationCode) {
        this.certificationCode = certificationCode;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", urgentName='" + urgentName + '\'' +
                ", urgentNumber='" + urgentNumber + '\'' +
                ", isAdmin='" + isAdmin + '\'' +
                ", role=" + role +
                ", avator='" + avator + '\'' +
                ", isValid='" + isValid + '\'' +
                ", password='" + password + '\'' +
                ", certificationCode='" + certificationCode + '\'' +
                '}';
    }
}
